package com.mice.microserviceconsumer.controller;

import com.mice.microserviceconsumer.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Created by AmbitiousMice on 2018/9/12.
 */
@RestController
public class UserController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/user/{id}")
    public User findById(@PathVariable Integer id){

        return restTemplate.getForObject("http://127.0.0.1:8080/user/"+id,User.class);
    }
}
